Skip to content

Conversation

@CodeVishal-17
Copy link
Contributor

@CodeVishal-17 CodeVishal-17 commented Jan 5, 2026

What does this PR do?

Exposes the weights_only argument in Fabric.load() and forwards it to the underlying strategy checkpoint loading call.

This restores compatibility with mixed-object checkpoints after the PyTorch 2.6 change where torch.load defaults to weights_only=True.

Motivation and context

With PyTorch 2.6, torch.load defaults to weights_only=True, which prevents loading checkpoints that contain non-tensor objects (such as optimizers, schedulers, or metadata).

While strategy.load_checkpoint(..., weights_only=False) already supports this use case, Fabric.load() did not expose the argument, making it impossible for users to opt out of the new default behavior when using Fabric.

This PR adds a keyword-only weights_only argument to Fabric.load() without changing the existing default behavior.

Fixes #21459

Before submitting
  • Was this discussed/agreed via a GitHub issue? ✔️ (see Fabric.load is missing the weights_only argument #21459)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--21470.org.readthedocs.build/en/21470/

@github-actions github-actions bot added the fabric lightning.fabric.Fabric label Jan 5, 2026
@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87%. Comparing base (affee28) to head (3aee89c).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #21470   +/-   ##
=======================================
- Coverage      87%      87%   -0%     
=======================================
  Files         270      270           
  Lines       24059    24059           
=======================================
- Hits        20858    20855    -3     
- Misses       3201     3204    +3     

@bhimrazy bhimrazy changed the title Expose weights_only argument in Fabric.load Expose weights_only argument for loading checkpoints in Fabric.load() and Fabric.load_raw() Jan 12, 2026
@tchaton tchaton merged commit 2060299 into Lightning-AI:master Jan 12, 2026
124 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fabric lightning.fabric.Fabric

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fabric.load is missing the weights_only argument

4 participants